﻿using Application;
using Application.Core.IoC;
using Application.Interfaces.Caching;
using Application.Interfaces.Email;
using Application.Interfaces.Encryption;
using Application.Interfaces.Logging;
using Application.Interfaces.Mapping;
using Application.Interfaces.Repository;
using Infrastructure.Core.Ioc.StructureMap;
using Infrastructure.Implementations.Caching;
using Infrastructure.Implementations.Email;
using Infrastructure.Implementations.Encryption;
using Infrastructure.Implementations.Logging;
using Infrastructure.Implementations.Mapping;
using Infrastructure.Implementations.Repository.EntityFramework;
using Web.Infrastructure.Mvc.Authentication;

namespace Web.Infrastructure
{
    public static class AppStart
    {
        public static void Config()
        {
            //init
            AppEngine.Init(new StructureMapContainer());

            //map
            AppEngine.Container.Add<IMapper, DefaultMapper>(Lifecycle.Singleton);
            AppEngine.Container.Add<ILogger, Log4NetLogger>(Lifecycle.UniquePerRequest);
            AppEngine.Container.Add<ICacheManager, MemoryCacheManager>(Lifecycle.UniquePerRequest);
            AppEngine.Container.Add<IEmailSender, SmtpEmailSender>(Lifecycle.UniquePerRequest);
            AppEngine.Container.Add<IEncryptionService, EncryptionService>(Lifecycle.UniquePerRequest);
            AppEngine.Container.Add<IFormsAuthentication, AspFormsAuthentication>(Lifecycle.UniquePerRequest);
            AppEngine.Container.Add(typeof(IRepository<>), typeof(EfRepository<>), Lifecycle.Transient);
            //config
            AppEngine.Container.Config();
        }
    }
}